﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using TransCend.Model;

namespace TransCend.DAL
{
    public class CommonDALFactory
    {
        private static readonly ICommonDAL commonDAL = new CommonDAL();
        public static ICommonDAL GetCommonDAL()
        {
            return commonDAL;
        }

        public static T GetDAL<T>()
        {
            Assembly demoAssebly = Assembly.GetExecutingAssembly();
            Type daltype = typeof(T);
            string DALFullname = daltype.Namespace.Replace(".IDAL", ".DAL") + "." + daltype.Name.Substring(1);
            T dal = (T)demoAssebly.CreateInstance(DALFullname);
            return dal;
        }
    }
}
